/**
 * 
 */
package scriptrunner.execution;

import java.io.Serializable;

/**
 * @author Administrator
 * 
 */
public class EvalUnaryMinusExpr extends EvaluateExpr implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8709397323009811878L;

	/**
	 * 
	 */
	public EvalUnaryMinusExpr(EvaluateExpr ee) {
		this.ee = ee;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * scriptrunner.execution.EvaluateExpr#CalculateResult(scriptrunner.execution
	 * .Session)
	 */
	@Override
	public ValueObject CalculateResult(Session se) throws ExecuteErrorException {
		ValueObject v = ee.CalculateResult(se);

		if (v instanceof ArithmeticCalculable) {
			ArithmeticCalculable a = (ArithmeticCalculable) v;
			return a.UnaryMinus();
		} else
			throw new ExecuteErrorException("Unary minus operation failed");
	}

	protected EvaluateExpr ee;
}
